/**
 * 上传路由
 * 定义文件上传相关的API端点
 */

import express from 'express';
import { authenticate } from '../middlewares/auth.js';
import { uploadSingle, uploadMultiple, handleMulterError } from '../middlewares/upload.js';
import * as uploadController from '../controllers/uploadController.js';

const router = express.Router();

// 所有上传路由都需要认证
router.use(authenticate);

/**
 * POST /api/v1/upload/ocr
 * 上传单张图片并进行OCR识别
 */
router.post(
  '/ocr',
  uploadSingle,
  handleMulterError,
  uploadController.uploadAndRecognize
);

/**
 * POST /api/v1/upload/ocr/batch
 * 上传多张图片并进行批量OCR识别
 */
router.post(
  '/ocr/batch',
  uploadMultiple,
  handleMulterError,
  uploadController.uploadAndRecognizeMultiple
);

export default router;

